/*     */ package com.cr.common.utils;
/*     */ 
/*     */ import java.lang.management.ManagementFactory;
/*     */ import java.text.ParseException;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.Date;
/*     */ import org.apache.commons.lang3.time.DateFormatUtils;
          import org.apache.commons.lang3.time.DateUtils;
/*     */

/*     */
/*     */ public class MyDateUtils extends DateUtils {
/*  16 */   public static String YYYY = "yyyy";
/*     */   
/*  18 */   public static String YYYY_MM = "yyyy-MM";
/*     */   
/*  20 */   public static String YYYY_MM_DD = "yyyy-MM-dd";
/*     */   
/*  22 */   public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
/*     */   
/*  24 */   public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
/*     */   
/*  26 */   private static String[] parsePatterns = new String[] { 
/*  26 */       "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", 
/*  26 */       "yyyy.MM.dd HH:mm", "yyyy.MM" };
/*     */   
/*     */   public static Date getNowDate() {
/*  38 */     return new Date();
/*     */   }
/*     */   
/*     */   public static String getDate() {
/*  48 */     return dateTimeNow(YYYY_MM_DD);
/*     */   }
/*     */   
/*     */   public static final String getTime() {
/*  53 */     return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
/*     */   }
/*     */   
/*     */   public static final String dateTimeNow() {
/*  58 */     return dateTimeNow(YYYYMMDDHHMMSS);
/*     */   }
/*     */   
/*     */   public static final String dateTimeNow(String format) {
/*  63 */     return parseDateToStr(format, new Date());
/*     */   }
/*     */   
/*     */   public static final String dateTime(Date date) {
/*  68 */     return parseDateToStr(YYYY_MM_DD, date);
/*     */   }
/*     */   
/*     */   public static final String parseDateToStr(String format, Date date) {
/*  73 */     return (new SimpleDateFormat(format)).format(date);
/*     */   }
/*     */   
/*     */   public static final Date dateTime(String format, String ts) {
/*     */     try {
/*  80 */       return (new SimpleDateFormat(format)).parse(ts);
/*  82 */     } catch (ParseException e) {
/*  84 */       throw new RuntimeException(e);
/*     */     } 
/*     */   }
/*     */   
/*     */   public static final String datePath() {
/*  93 */     Date now = new Date();
/*  94 */     return DateFormatUtils.format(now, "yyyy/MM/dd");
/*     */   }
/*     */   
/*     */   public static final String dateTime() {
/* 102 */     Date now = new Date();
/* 103 */     return DateFormatUtils.format(now, "yyyyMMdd");
/*     */   }
/*     */   
/*     */   public static Date parseDate(Object str) {
/* 111 */     if (str == null)
/* 113 */       return null; 
/*     */     try {
/* 117 */       return parseDate(str.toString(), parsePatterns);
/* 119 */     } catch (ParseException e) {
/* 121 */       return null;
/*     */     } 
/*     */   }
/*     */   
/*     */   public static Date getServerStartDate() {
/* 130 */     long time = ManagementFactory.getRuntimeMXBean().getStartTime();
/* 131 */     return new Date(time);
/*     */   }
/*     */   
/*     */   public static int differentDaysByMillisecond(Date date1, Date date2) {
/* 139 */     return Math.abs((int)((date2.getTime() - date1.getTime()) / 86400000L));
/*     */   }
/*     */   
/*     */   public static String getDatePoor(Date endDate, Date nowDate) {
/* 147 */     long nd = 86400000L;
/* 148 */     long nh = 3600000L;
/* 149 */     long nm = 60000L;
/* 152 */     long diff = endDate.getTime() - nowDate.getTime();
/* 154 */     long day = diff / nd;
/* 156 */     long hour = diff % nd / nh;
/* 158 */     long min = diff % nd % nh / nm;
/* 161 */     return day + "天" + hour + "小时" + min + "分钟";
/*     */   }
/*     */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\lib\creditorRights-common-4.7.0.jar!\com\cr\commo\\utils\DateUtils.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */